package org.xtremeobjects.domain.model.java5;

import java.lang.reflect.Method;

class PropertyGetterSpecification extends AbstractMethodSpecification {

	private boolean association = false;

	PropertyGetterSpecification() {
	}

	PropertyGetterSpecification(boolean association) {
		this.association = association;
	}

	@Override
	public boolean isSatisfiedBy(Method method) {

		if(isHidden(method))
			return false;
			/**/
		
		// is a getter
		if (!isGetter(method))
			return false;

		// is a getClass()
		if (isClassGetter(method))
			return false;

		// looking for associations and is not an array or collection
		if (association == true && (!isArray(method) && !isCollection(method)))
			return false;

		// looking for properties and is not an array or collection
		if (association == false && (isArray(method) || isCollection(method)))
			return false;

		return true;
	}

}
